class PopsiclesController < ApplicationController
  # GET /popsicles
  # GET /popsicles.xml
  def index
    @popsicles = Popsicle.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @popsicles }
    end
  end

  # GET /popsicles/1
  # GET /popsicles/1.xml
  def show
    @popsicle = Popsicle.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @popsicle }
    end
  end

  # GET /popsicles/new
  # GET /popsicles/new.xml
  def new
    @popsicle = Popsicle.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @popsicle }
    end
  end

  # GET /popsicles/1/edit
  def edit
    @popsicle = Popsicle.find(params[:id])
  end

  # POST /popsicles
  # POST /popsicles.xml
  def create
    @popsicle = Popsicle.new(params[:popsicle])

    respond_to do |format|
      if @popsicle.save
        format.html { redirect_to(@popsicle, :notice => 'Popsicle was successfully created.') }
        format.xml  { render :xml => @popsicle, :status => :created, :location => @popsicle }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @popsicle.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /popsicles/1
  # PUT /popsicles/1.xml
  def update
    @popsicle = Popsicle.find(params[:id])

    respond_to do |format|
      if @popsicle.update_attributes(params[:popsicle])
        format.html { redirect_to(@popsicle, :notice => 'Popsicle was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @popsicle.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /popsicles/1
  # DELETE /popsicles/1.xml
  def destroy
    @popsicle = Popsicle.find(params[:id])
    @popsicle.destroy

    respond_to do |format|
      format.html { redirect_to(popsicles_url) }
      format.xml  { head :ok }
    end
  end
end
